﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ProcessManager
{
    public class LogHelper
    {
        public static string LogFolderPath = Application.StartupPath + "\\Logs";
        public LogHelper() { }

        public static void WriteLog(string logStr)
        {
            if (!Directory.Exists(LogFolderPath))
            {
                Directory.CreateDirectory(LogFolderPath);
            }

            string logFilePath = LogFolderPath + "\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
            if (!File.Exists(logFilePath))
            {
                File.Create(logFilePath);
            }

            Object thisFunc = new object();
            lock (thisFunc)
            {
                File.AppendAllText(logFilePath, DateTime.Now.ToString() + " : " + logStr + "\r\n");
            }
        }

    }
}
